package com.code.pattern.singleton.hungry;

/**
 * 饿汉式 - 静态代码块方式
 * @author: liyufei
 * @date: 2021-03-15 21:53
 */
public class HungryStaticSingleton {

    private static final HungryStaticSingleton hungrySingleton;

    /**
     * 类加载的时候就把对象创建出来了
     */
    static {
        hungrySingleton = new HungryStaticSingleton();
    }

    private HungryStaticSingleton() {}

    public static HungryStaticSingleton getInstance() {
        return hungrySingleton;
    }
}
